﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CrystalDecisions.CrystalReports.Engine;

public partial class Admin_BaoCaoDoanhThuBang : System.Web.UI.Page
{
    protected void checkAlreadyLogin()
    {
        if (Session["UserID"].ToString() == null)//Session["UserType"].ToString() != "QuanTri" ||
        {
            Response.Redirect("Login.aspx");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            checkAlreadyLogin();
            ReportDocument crystalReport = new ReportDocument();
            crystalReport.Load(Server.MapPath("~/Admin/DoanhThuBanHangTheoBang.rpt"));
            crystalReport.SetDatabaseLogon("sa", "123", @"NHI-PC\SQLEXPRESS", "DBTGBE");
            crystalReport.Refresh();
            try
            {
                crystalReport.SetParameterValue("@Nam", Request["nam"]);
            }
            catch
            {
                //ScriptManager.RegisterStartupScript(this, this.GetType(), "alert",
                //   "alert('Đường dẫn bị sai!Yêu cầu nhập lại');", true);
                Response.Redirect("NotFound.aspx");
            }
            crDoanhThuTheoBang.ReportSource = crystalReport;
        }
    }

}